package com.wdy.golden.tinysql.enmus;

/**  
 * @author Dongye_Wu
 * @version: 1.0.0
 * @Description: TODO
 * @date 2020年4月10日 下午7:03:11 
 */
public enum TinysqlSchema {

	//TINYSQL
	TINYSQL("tinysql", 1),

	//INTERFACE
	INTERFACE("interface", 2),
	INTERFACE_ATTR_NAME("name", 2),

	//RESULTMAP
	RESULTMAP("resultMap", 2),
	RESULTMAP_ATTR_NAME("name", 2),
	//RESULTMAP Child
	RESULTMAP_CHILD_RESULT("result", 3),
	MAPPING_ATTR_COLUMN("column", 3),
	MAPPING_ATTR_PROPERTY("property", 3),
	MAPPING_ATTR_SEPARATOR("separator", 3),
	
	//SCRIPT
	SCRIPT("script", 2),
	SCRIPT_ATTR_METHOD("method", 2),
	SCRIPT_ATTR_RESULTMAPREF("resultMapRef", 2),
	//SCRIPT Child
	SCRIPT_CHILD_WHERE("where", 3),
	SCRIPT_CHILD_NVLIGNORE("nvlIgnore", 3),
	SCRIPT_CHILD_CONDITION("condition", 3),
	SCRIPT_CHILD_ORDERBY("orderBy", 3),
	SCRIPT_CHILD_LIKE("like", 3),
	SCRIPT_CHILD_PAGINATION("pagination", 3),
	SCRIPT_CHILD_SUPERPAGINATION("superPagination", 3),
	SCRIPT_CHILD_PARAMIN("paramIn", 3),
	SCRIPT_CHILD_BATCHPARAMS("batchParams", 3),
	SCRIPT_CHILD_NVLLISTIGNORE("nvlListIgnore", 3),
	SCRIPT_CHILD_NVLLISTEXEC("nvlListExec", 3),
	SCRIPT_CHILD_NVLEXEC("nvlExec", 3),
	//SCRIPT Child Attr
	NVLIGNORE_ATTR_SEPARATE("separate", 3),
	NVLIGNORE_ATTR_PARAMS("params", 3),
	NVLIGNORE_ATTR_PARAM("param", 3),
	NVLIGNORE_ATTR_VALUE("value", 3),
	CONDITION_ATTR_PARAM("param", 3),
	CONDITION_ATTR_VALUE("value", 3),
	ORDERBY_ATTR_PARAM("param", 3),
	LIKE_ATTR_TYPE("type", 3),
	LIKE_ATTR_SEPARATE("separate", 3),
	LIKE_ATTR_PARAM("param", 3),
	PAGINATION_ATTR_ROWSTARTPARAM("rowStartParam", 3),
	PAGINATION_ATTR_ROWENDPARAM("rowEndParam", 3),
	PARAMIN_ATTR_NAME("name", 3),
	PARAMIN_ATTR_PARAM("param", 3),
	BATCHPARAMS_ATTR_PARAMS("params", 3),
	NVLLISTIGNORE_ATTR_SEPARATE("separate", 3),
	NVLLISTIGNORE_ATTR_PARAMS("params", 3),
	NVLEXEC_ATTR_SEPARATE("separate", 3),
	NVLEXEC_ATTR_PARAMS("params", 3),
	NVLLISTEXEC_ATTR_SEPARATE("separate", 3),
	NVLLISTEXEC_ATTR_PARAMS("params", 3),
	;

	public String name;
	public int index;

	private TinysqlSchema(String name, int index) {
		this.name = name;
		this.index = index;
	}

	public static String getName(int index) {
		for (TinysqlSchema c : TinysqlSchema.values()) {
			if (c.getIndex() == index) {
				return c.name;
			}
		}
		return null;
	}
	
	public String getName() {
		return name;
	}

	public int getIndex() {
		return index;
	}
}
